package main.java.peopleinfo;

import java.io.IOException;

import main.java.peopleinfo.PeopleInfo;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

//                                                               ???        ????
public class PeopleInfoReducer extends Reducer<Text, PeopleInfo, Text, IntWritable> {

	@Override
	protected void reduce(Text key3, Iterable<PeopleInfo> value3,Context context) throws IOException, InterruptedException {
		// ???弸????????????
		int totalNumber = 0; //??????
		int highest = 0;//??????
		int lowest = 10000 ; //????  ??????
		
		for(PeopleInfo p:value3){
			//??????+1
			totalNumber ++;
			
			//?????????????
			if(p.getHeight() > highest){
				highest = p.getHeight();
			}
			
			if(p.getHeight() < lowest){
				lowest = p.getHeight();
			}
		}
		
		//???
		context.write(new Text("Total: "), new IntWritable(totalNumber));
		context.write(new Text("highest: "), new IntWritable(highest));
		context.write(new Text("lowest: "), new IntWritable(lowest));
	}

}














